// pages/recharge-list/index.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    CurrentPage:1,
    recordList:[],
    loadingMoreHidden:false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.cashRecordList()
  },
  //获取充值列表
  cashRecordList:function(){
    var that = this
    wx.request({
      url: app.globalData.host + '/api/UserCash/CashRecordList?uid=' + app.globalData.userInfo.Uid + '&page=' + that.data.CurrentPage,
      success: function(res) {
       if(res.data.Code == 0){
         var recordList = res.data.Data.List.Items
         if (that.data.CurrentPage != 1) {
           var preGoods = that.data.recordList
           recordList = preGoods.concat(recordList);
         }
         that.setData({
           recordList: recordList,
           loadingMoreHidden: res.data.Data.PageModel.HasNextPage
         })
       }
      },
    })
  },

  //加载更多
  loadMore: function (e) {
    var that = this;
    if (!that.data.loadingMoreHidden) return;
    var currPage = that.data.CurrentPage;
    that.setData({
      CurrentPage: currPage + 1
    })
    that.cashRecordList();
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  }
})